/*
 * SRTFscheduler.h
 *
 *  Created on: Jun 28, 2009
 *      Author: yanir
 */

#ifndef SRTFSCHEDULER_H_
#define SRTFSCHEDULER_H_

#include "OSScheduler.h"
#include "Mailer.h"
#include "quantaComp.h"
#include <queue>
#include <vector>

class SRTFscheduler : public OSScheduler
{
	//typedef map<string,TT> threadsTable ;
	private:

	priority_queue< Worker* ,vector<Worker*> ,quantaComp > m_blocked_threads; /* a queue of blocked threads */

	priority_queue< Worker* ,vector<Worker*> ,quantaComp > m_active_threads;  /* a queue of active threads */


	Mailer* m_mailer;

	map<string, Worker>* m_workers;


	int m_contex_switch_count;

	int m_quanta_count;

	int m_msg_passed_count;

	int m_phase_count;

//	threadsTable*  m_tT;
	public:

	/* C'tor  */
	SRTFscheduler();

	SRTFscheduler(map<string, Worker>* workers ,Mailer* mailer);


	virtual ~SRTFscheduler();


	/* init scheduler*/
	void init();

	/*next worker*/

	void nextWorker();
	//void* getThreadsTable();


	//map<string, Worker>* getWorkers();

	/* increment the contex switches count by 1 */
	void incCScount();

	/* increment the quanta given count by 1 */
	void incQuantaCount();

	/* increment the message passed count by 1 */
	void incMsgPass();

	bool isStable();

	void printSum();






};

#endif /* SRTFSCHEDULER_H_ */
